///: Replication script for: The Role of Judge Gender and Ideology in Hiring Female Law Clerks
///: Authors: Alex Badas, Bailey K. Sanders, and Katelyn E. Stauffer
///: Journal: Journal of Law and Courts 


clear

log using "BadasSandersStaufferJLCreplication.log", replace

use "BadasSandersStaufferJCLdata.dta"

///: Figure 1 
twoway (histogram cfscore if FemaleClerk==1 , percent width(.15) color(blue%25)) ///
       (histogram cfscore if FemaleClerk==0 & cfscore > -.4, percent width(.15) ///        
	   color(red%25)) ///
	   (histogram judgecfimputed if FemaleJudge==1, percent width(.15) color(black%25)) ///
	   (histogram judgecfimputed if FemaleJudge==0, percent width(.15) color(green%25)), ///
	   legend (order(1 "Female Clerks" 2 "Male Clerks" 3 "Female Judges" 4 "Male Judges") /// 
	   on ring(0))
	   
	   
///: Table 1
logit FemaleClerk i.FemaleJudge  i.CourtType same  judgecfimputed  i.year 


///: Figure 2
margins FemaleJudge, plot

///: Figure 3
margins, at(judgecfimputed=(-1.5(.5)1.67)) 
marginsplot, title(Ideology and Hiring Women Clerks) plot1opts(color(black)msymbol(none) lwidth(medthick) ///
xtitle(Judge Conservativism (CF Score)) ytitle("Predicted Probability" "Hiring Women Clerk")) ///
recastci(rarea)  ///
ciopts(color(gs10%85)alwidth(none)) ///
addplot(hist judgecfimputed, fcolor(gs1%30) lwidth(none) ///
percent ///
yaxis(2) ///
yscale(alt lcolor(gs10) axis(2)) ///
ylabel(0 "0%" 5 "5%" 10 "10%" 30 " "  , /// 
labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) /// 
ytitle(" ", axis(2)) /// 
xlabel(-1.5(1)1.67) ///
legend(off))

///: Table  2
logit FemaleClerk i.FemaleJudge##c.judgecfimputed i.CourtType same  i.year 

///: Figure 4, Right Panel
margins, dydx(FemaleJudge) at(judgecfimputed=(-1.5(.15)1.67)) 
marginsplot, title(Ideology and Hiring Women Clerks) plot1opts(color(black)msymbol(none) lwidth(medthick) ///
xtitle(Judge Conservativism (CF Score)) ytitle("Predicted Probability" "Hiring Women Clerk")) ///
recastci(rarea)  ///
ciopts(color(gs10%85)alwidth(none)) ///
addplot(hist judgecfimputed, fcolor(gs1%30) lwidth(none) ///
percent ///
yaxis(2) ///
yscale(alt lcolor(gs10) axis(2)) ///
ylabel(0 "0%" 5 "5%" 10 "10%" 30 " "  , /// 
labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) /// 
ytitle(" ", axis(2)) /// 
xlabel(-1.5(1)1.67) ///
ylabel(-.05(.025).1) ///
yline(0) ///
legend(off))

///: Figure 4, Left Panel 
margins, by(FemaleJudge) at(judgecfimputed=(-1.5(.15)1.67)) 
marginsplot, title(Ideology and Hiring Women Clerks) plot1opts(color(black)msymbol(none) lwidth(medthick) ///
xtitle(Judge Conservativism (CF Score)) ytitle("Predicted Probability" "Hiring Women Clerk")) ///
recastci(rarea)  ///
ciopts(color(gs10%85)alwidth(none)) ///
addplot(hist judgecfimputed, fcolor(gs1%30) lwidth(none) ///
percent ///
yaxis(2) ///
yscale(alt lcolor(gs10) axis(2)) ///
ylabel(0 "0%" 5 "5%" 10 "10%" 30 " "  , /// 
labcolor() axis(2) tlcolor(black) tlwidth(thin) labsize(small)) /// 
ytitle(" ", axis(2)) /// 
xlabel(-1.5(1)1.67) ///
yline(0) ///
legend(off))



///: Figure 4
histogram IdeologicalDistance if IdeologicalDistance <4



///: Table 3
reg IdeologicalDistance (i.FemaleJudge c.judgecfimputed)##i.FemaleClerk cfscore previous Total samelaw  i.year i.CourtType 


///: Figure 6
///: Figure 6 requires downloading the mplotoffset package
ssc install mplotoffset 

margins FemaleJudge, by(FemaleClerk) 
mplotoffset, offset(.02) legend(ring(0))


///: Figure 7
margins, dydx(FemaleClerk) at(judgecfimputed=(-1.5(.5)1.5)) plot(recastci(rarea))
margins FemaleClerk, at(judgecfimputed=(-1.5(.5)1.5)) plot(recastci(rarea) legend(ring(0)))


clear

log close
